package com.starinside.wp.controller.api;

import com.starinside.wp.components.MemVerificationCache;
import com.starinside.wp.domain.develop.DevelopReview;
import com.starinside.wp.domain.develop.DevelopReviewItem;
import com.starinside.wp.domain.develop.PO.DevelopDetailsListPO;
import com.starinside.wp.domain.develop.PO.DevelopDetailsPO;
import com.starinside.wp.domain.develop.PO.DevelopReviewPO;
import com.starinside.wp.foundation.constant.RequestConstant;
import com.starinside.wp.foundation.ext.aliyun.OSSProcessService;
import com.starinside.wp.foundation.model.StatusResponse;
import com.starinside.wp.foundation.query.base.PagerQuery;
import com.starinside.wp.service.DevelopReviewService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;



@RestController
@RequestMapping("//wx/api/developReview")
@Api(value ="/wx/api/developReview", tags = "教学 - 发展检核")
public class APIDevelopReviewController {

    @Autowired
    private DevelopReviewService developReviewService;


    @Autowired
    protected MemVerificationCache cache;

    @Autowired
    private OSSProcessService ossProcessService;

    @Value("${aliyun.oss.fileServerPrefix}")
    private String IMG_SERVICE_PREFIX;

    @ApiOperation(value = "月份 - 列表")
    @PostMapping("/month_list")
    @ApiResponses({
            @ApiResponse(code = 000000, message = "successful", response = DevelopReview.class),
    })
    public StatusResponse monthList() {
        List<DevelopReview> list = developReviewService.monthList();
        return StatusResponse.success(list);
    }

    @ApiOperation(value = "月份 - 默认项目")
    @PostMapping("/month_item_list")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "ticket", value = "票据", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "developId", value = "发展核减月ID", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 000000, message = "successful", response = DevelopReviewPO.class),
    })
    public StatusResponse monthItemList(@RequestHeader(RequestConstant.TICKET) String ticket,String developId) {
        List<DevelopReviewItem> list = developReviewService.monthItemList(developId);
        return StatusResponse.success(list);
    }


//    @ApiOperation(value = "记录 - 添加")
//    @PostMapping("/add_user_month")
//    @ApiImplicitParams({
//            @ApiImplicitParam(paramType = "header", name = "ticket", value = "票据", required = true, dataType = "string"),
//    })
//    public StatusResponse add(@RequestHeader(RequestConstant.TICKET) String ticket, AddUserMonthVO addUserMonth) {
//        StaffDTO staff = cache.getStaff(ticket);
//        developReviewService.addUserMonth(staff, addUserMonth.getChildrenIds(), addUserMonth.getClassId(),addUserMonth.getDevelopId(), staff.getRealName(),addUserMonth.getRemarks(),addUserMonth.getList());
//        return StatusResponse.success("添加成功");
//    }
//
//
//    @ApiOperation(value = "班级人员 - 统计列表")
//    @PostMapping("/count")
//    @ApiImplicitParams({
//            @ApiImplicitParam(paramType = "header", name = "ticket", value = "票据", required = true, dataType = "string"),
//            @ApiImplicitParam(paramType = "query", name = "classId", value = "班级ID", required = false, dataType = "string"),
//            @ApiImplicitParam(paramType = "query", name = "name", value = "学生名称", required = false, dataType = "string"),
//    })
//    @ApiResponses({
//            @ApiResponse(code = 000000, message = "successful", response = DevelopCountPO.class),
//    })
//    public StatusResponse count(@RequestHeader(RequestConstant.TICKET) String ticket, String classId, String name,PagerQuery pagerQuery) {
//        StaffDTO staff = cache.getStaff(ticket);
//        Page<DevelopCountPO> developCountPO = developReviewService.count( staff.getAreaId(), classId,name,pagerQuery);
//        return StatusResponse.success(developCountPO);
//    }


    @ApiOperation(value = "核检单人 - 详情列表")
    @PostMapping("/childrenDetailsList")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "ticket", value = "票据", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "childrenId", value = "宝宝ID", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 000000, message = "successful", response = DevelopDetailsListPO.class),
    })
    public StatusResponse childrenDetailsList(@RequestHeader(RequestConstant.TICKET) String ticket, String childrenId,PagerQuery pagerQuery) {
        Page<DevelopDetailsListPO> list = developReviewService.childrenDetailsList( childrenId,pagerQuery);
        return StatusResponse.success(list);
    }


    @ApiOperation(value = "核检单人 - 详情")
    @PostMapping("/childrenDetails")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "ticket", value = "票据", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "developUserId", value = "核检记录ID", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 000000, message = "successful", response = DevelopDetailsPO.class),
    })
    public StatusResponse childrenDetails(@RequestHeader(RequestConstant.TICKET) String ticket,String  developUserId) {
        DevelopDetailsPO developDetails = developReviewService.childrenDetails( developUserId);
        return StatusResponse.success(developDetails);
    }

}
